<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @author Anh Nguyen <duyanhnguyen@vccorp.vn>
 * @copyright 2012
 */

class Admin_Layout
{
    private $_CI;

    function __construct()
    {
        $this->_CI =& get_instance();
        $this->_CI->load->library('Minifier');
        $this->_CI->load->library('Blockcache');
    }
    
    public function _loadHeader($headTitle = '')
    {
        $data = array();
        $data['headTitle'] = $headTitle;
        $this->addCssJs();
        $data['combinedCss'] = $this->_CI->minifier->GetCombined('css');
        $data['combinedJs'] = $this->_CI->minifier->GetCombined('js');
        $this->_CI->load->view('header_view',$data);
    }
    
    public function _loadFooter()
    {
        $this->_CI->load->view('footer_view');
    }
    
    public function _loadLeftMenu($data = array())
    {
        $this->_CI->load->view('leftmenu_view', $data);
    }
    
    public function addCssJs()
    {
        $this->_CI->minifier->AddCss('reset');
        $this->_CI->minifier->AddCss('grids');
        $this->_CI->minifier->AddCss('style');
        $this->_CI->minifier->AddCss('datepicker-1');
        $this->_CI->minifier->AddCss('jquery.uniform');
        $this->_CI->minifier->AddCss('forms');
        $this->_CI->minifier->AddCss('themes/lightblue/style');
        $this->_CI->minifier->AddCss('cleanslate');
        
        $this->_CI->minifier->AddSharedJs('jquery-1.8.2.min');
        $this->_CI->minifier->AddSharedJs('datepicker');
        $this->_CI->minifier->AddSharedJs('jquery.tools.min');
        $this->_CI->minifier->AddSharedJs('jquery.uniform.min');
        $this->_CI->minifier->AddSharedJs('jquery.tablesorter');
        $this->_CI->minifier->AddSharedJs('jquery.meio.mask');
        $this->_CI->minifier->AddSharedJs('global');
        $this->_CI->minifier->AddJsNoPack('custom');
        $this->_CI->minifier->AddJsNoPack('ckeditor/ckfinder/ckfinder');
    }
    
    public function render($viewFile, $data = array())
    {
        $headTitle = (isset($data['headTitle'])) ? $data['headTitle'] : '';
        $this->_loadHeader($headTitle);
        $this->_loadLeftMenu($data);
        $this->_CI->load->view($viewFile, $data);
        $this->_loadFooter();
    }

}

?>